package com.yytek.am.core.runtime;

import akka.actor.ActorRef;
import com.yytek.am.core.msg.EventRuleClearUpdateMessage;
import com.yytek.am.core.msg.EventRuleGenerateUpdateMessage;
import com.yytek.am.core.msg.EventRuleUpdateMessage;
import com.yytek.am.core.rule.EventRule;
import com.yytek.am.core.rule.EventRuleClear;
import com.yytek.am.core.rule.EventRuleGenerate;

public class RuleManager {
	private ActorRef eventManager;

	public RuleManager(ActorRef eventManager) {
		this.eventManager = eventManager;
	}

	/**
	 * 修改或删除告警定义
	 * @param type
	 * @param eventRule
	 */
	public void updateEventRule(int type, EventRule eventRule) {
		eventManager.tell(new EventRuleUpdateMessage(type, eventRule), ActorRef.noSender());
	}

	/**
	 * 修改或删除告警生成规则
	 * @param type
	 * @param eventRuleGenerate
	 */
	public void updateEventRuleGenerate(int type, EventRuleGenerate eventRuleGenerate) {
		eventManager.tell(new EventRuleGenerateUpdateMessage(type, eventRuleGenerate), ActorRef.noSender());
	}

	/**
	 * 修改或删除告警清除规则
	 * @param type
	 * @param eventRuleClear
	 */
	public void updateEventRuleClear(int type, EventRuleClear eventRuleClear) {
		eventManager.tell(new EventRuleClearUpdateMessage(type, eventRuleClear), ActorRef.noSender());
	}

}
